package asyncTasks;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;

public class GetPlaceIcon extends AsyncTask<ArrayList<String>, Void, ArrayList<Bitmap>> {

	@Override
	protected ArrayList<Bitmap> doInBackground(ArrayList<String>... params) {
		    ArrayList<Bitmap> bitList = new ArrayList<Bitmap>();
			try {
					for(String URL : params[0]){
						URL url = new URL(URL);
			        	HttpURLConnection connection = (HttpURLConnection) url.openConnection();
			        	connection.setDoInput(true);
			        	connection.connect();
			        	InputStream input = connection.getInputStream();
			        	Bitmap myBitmap = BitmapFactory.decodeStream(input);
			        	myBitmap = Bitmap.createScaledBitmap(myBitmap, myBitmap.getWidth() / 2, myBitmap.getHeight() / 2, false);
			        	bitList.add(myBitmap);
					}
		        return bitList;
		    } catch (IOException e) {
		        e.printStackTrace();
		        return null;
		    }
	}
	
}
